home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / +look_here_1st!+ / reader_requests / voiceshell / source / vsconv.s < prev   
Text File  |  1997-12-05  |  18KB  |  1,005 lines

  1. *************************************************
  2. *                        *
  3. *        (C) Copyright 1993-95        *
  4. *                        *
  5. *           Tomi  Blinnikka        *
  6. *                        *
  7. *    Don't try to understand the code    *
  8. *                        *
  9. * Version 1.00    15.08.1993            *
  10. *           -03.03.1993            *
  11. * BUGS:                        *
  12. *                        *
  13. * Not finished.                    *
  14. *                        *
  15. * Version 1.01    03.01.1995            *
  16. *                        *
  17. * Should now support all file types.        *
  18. *                        *
  19. *************************************************
  20.  
  21.     INCLUDE    "JMPLibs.i"
  22.     INCLUDE    "libraries/dos.i"
  23.  
  24.     INCLUDE    "XREF:2.0.xref"
  25.     INCLUDE    "XREF:exec.xref"
  26.     INCLUDE    "XREF:dos.xref"
  27.  
  28.     INCLUDE    "libraries/voice.i"
  29.  
  30. PROGVERSION:    macro
  31.         dc.b    "1.01 (03.01.95)"
  32.         endm
  33.  
  34. DefAccVal:    EQU    3000        ;VoiceShell default
  35.  
  36. ;VSFileVersion    'VS02', oldest supported type
  37.  
  38. GADLENG1VS02:    EQU    16
  39. GADLENG2VS02:    EQU    64
  40. GADLENGTHVS02:    EQU    (GADLENG1VS02+GADLENG2VS02)
  41.  
  42. ;VSFileVersion    'VS03', has longer command strings than 02
  43.  
  44. VocabSIZE:    EQU    60
  45. GADLENG1:    EQU    16
  46. GADLENG2:    EQU    256
  47. GADLENGTH:    EQU    (GADLENG1+GADLENG2)
  48. VSMB_Size:    EQU    VocabSIZE*304
  49.  
  50. ;VSFileVersion 'VS04', has error commands (9*GADLENG2), Wakeup and
  51. ;confirmation
  52.  
  53. ;VSFileVersion 'VS05', prefs and data file joined, PrefsWake length
  54. ;changed from byte to word
  55.  
  56. VS02Length:    EQU    23040
  57. VS03Length:    EQU    34560
  58. VS04Length:    EQU    36864
  59. VS05Length:    EQU    36902
  60.  
  61. VSHEADER_SIZE:    EQU    4
  62.  
  63. ;VCLI version 7.0
  64.  
  65. VCLIVocabSIZE:    EQU    48
  66. VCLIMB_Size:    EQU    VCLIVocabSIZE*304
  67.  
  68. NullBufSize1:    EQU    65536
  69.  
  70. TRUE:        EQU    1
  71. FALSE:        EQU    0
  72.  
  73.         section    VSConv,CODE
  74.  
  75.         openlib    Dos,NoDos
  76.  
  77.         lea.l    CLTemplate1,a0
  78.         move.l    a0,d1
  79.         lea.l    CLArray1,a0
  80.         move.l    a0,d2
  81.         clr.l    d3
  82.         lib    Dos,ReadArgs
  83.         move.l    d0,RDArgs1
  84.         beq    NoRDArgs
  85.  
  86.         lib    Dos,Output
  87.         move.l    d0,_stdout
  88.  
  89.         lib    Dos,Input
  90.         move.l    d0,_stdin
  91.  
  92.         lea.l    FromFileText1,a0
  93.         bsr    Printer
  94.         move.l    SourceFile1,a0
  95.         bsr    Printer
  96.         lea.l    CRLFText1,a0
  97.         bsr    Printer
  98.  
  99.         lea.l    FromFileText2,a0
  100.         bsr    Printer
  101.         move.l    SourceFile2,a0
  102.         bsr    Printer
  103.         lea.l    CRLFText1,a0
  104.         bsr    Printer
  105.  
  106.         lea.l    DestText1,a0
  107.         bsr    Printer
  108.         move.l    DestFile,a0
  109.         bsr    Printer
  110.         lea.l    CRLFText1,a0
  111.         bsr    Printer
  112.  
  113.         move.l    SourceFile1,d1
  114.         move.l    #MODE_OLDFILE,d2
  115.         lib    Dos,Open
  116.         move.l    d0,Source1
  117.         beq    NoRDArgs
  118.  
  119.         move.l    SourceFile2,d1
  120.         move.l    #MODE_OLDFILE,d2
  121.         lib    Dos,Open
  122.         move.l    d0,Source2
  123.  
  124.         move.l    DestFile,d1
  125.         move.l    #MODE_OLDFILE,d2
  126.         lib    Dos,Open
  127.         move.l    d0,Destination
  128.         beq    OpenDest2
  129.  
  130. OpenDest1:    lea.l    FExistsText1,a0
  131.         bsr    Printer
  132.  
  133.         bsr    GetYesNo
  134.         tst.l    d0
  135.         beq    OpenDest1
  136.  
  137.         cmp.l    #1,d0            ;Yes, replace
  138.         beq    OpenDest1.1
  139.  
  140.         cmp.l    #2,d0
  141.         beq    ShutDown
  142.  
  143.         move.l    #RETURN_FAIL,RetCode
  144.         bra    ShutDown        ;Error
  145.  
  146. OpenDest1.1:    move.l    Destination,d1        ;Close and reopen as new
  147.         lib    Dos,Close
  148.         clr.l    Destination
  149.  
  150. OpenDest2:    move.l    DestFile,d1
  151.         move.l    #MODE_NEWFILE,d2
  152.         lib    Dos,Open
  153.         move.l    d0,Destination
  154.         beq    NoRDArgs
  155.  
  156.         lea.l    CRLFText1,a0
  157.         bsr    Printer
  158.  
  159. ;Versions 02 - 04 must be checked by length since the data file didn't have
  160. ;a header at all... :(
  161.  
  162.         move.l    Source1,d1
  163.         bsr    GetFileLength
  164.         tst.l    d0
  165.         beq    NoRDArgs
  166.  
  167.         cmp.l    #VS02Length,d0
  168.         beq    DoVS02
  169.  
  170.         cmp.l    #VS03Length,d0
  171.         beq    DoVS03
  172.  
  173.         cmp.l    #VS04Length,d0
  174.         beq    DoVS04
  175.  
  176. ;These can be checked directly from the header
  177.  
  178.         move.l    Source1,d1
  179.         bsr    GetHeader
  180.         tst.l    d0
  181.         beq    NoRDArgs
  182.  
  183.         lea.l    VSVersion05,a0
  184.         lea.l    CopyBuffer1,a1
  185.         bsr    CmpStrings
  186.         tst.l    d0
  187.         bne    DoVS05
  188.  
  189.         lea.l    VCLI70ID,a0
  190.         lea.l    CopyBuffer1,a1
  191.         bsr    CmpStrings
  192.         tst.l    d0
  193.         bne    DoVCLI70
  194.  
  195.         lea.l    UnknownText1,a0
  196.         bsr    Printer
  197.  
  198.         lea.l    CopyBuffer1,a0
  199.         bsr    Printer
  200.  
  201.         lea.l    CRLFText1,a0
  202.         bsr    Printer
  203.  
  204.         bra    ShutDown
  205.  
  206. DoVS02:        lea.l    ConvText1,a0
  207.         bsr    Printer
  208.         lea.l    ConvText3,a0
  209.         bsr    Printer
  210.  
  211. ;Test for optional prefs file and get prefs if possible
  212.  
  213.         move.l    Source2,d1
  214.         beq    DoVS02.2
  215.         lea.l    CopyBuffer1,a0
  216.         move.l    a0,d2
  217.         move.l    #38,d3
  218.         lib    Dos,Read
  219.         cmp.l    d3,d0
  220.         bne    NoRDArgs
  221.  
  222.         lea.l    VSVersion02,a0
  223.         lea.l    CopyBuffer1,a1
  224.         bsr    CmpStrings
  225.         tst.l    d0
  226.         bne    DoVS02.1
  227.  
  228.         lea.l    IncVerText1,a0
  229.         bsr    Printer
  230.         move.l    #RETURN_WARN,RetCode
  231.         bra    DoVS02.2
  232.  
  233. DoVS02.1:    lea.l    CopyBuffer1,a0
  234.         add.l    #4,a0            ;Skip header
  235.         lea.l    DefPrefs,a1
  236.         add.l    #4,a1            ;Skip header
  237.         move.l    #14,d0
  238.         lib    Exec,CopyMem        ;Copy prefs, part I
  239.  
  240.         lea.l    CopyBuffer1,a0
  241.         lea.l    DefPrefs,a1
  242.         move.b    18(a0),19(a1)        ;Move wake correctly
  243.         move.l    34(a0),34(a1)        ;Move Alt(X/Y)Pos
  244.  
  245. DoVS02.2:    bsr    WriteDefPrefs
  246.         tst.l    d0
  247.         beq    NoRDArgs
  248.  
  249.         move.l    #VSMB_Size,d0
  250.         bsr    CopyMapBuffer
  251.         tst.l    d0
  252.         beq    NoRDArgs
  253.  
  254. ;Copy commands and patch length
  255.  
  256.         move.l    #VocabSIZE,d5
  257.  
  258. DoVS02.3:    bsr    CopyGL02Bytes
  259.         tst.l    d0
  260.         beq    NoRDArgs
  261.  
  262.         move.l    #(GADLENG2-GADLENG2VS02),d3    ;192 bytes
  263.         bsr    WriteNulls
  264.         tst.l    d0
  265.         beq    NoRDArgs
  266.  
  267.         sub.l    #1,d5
  268.         bne    DoVS02.3            ;Do until end
  269.  
  270. ;Error commands
  271.  
  272.         move.l    #(9*GADLENG2),d3        ;2304 bytes
  273.         bsr    WriteNulls
  274.         tst.l    d0
  275.         beq    NoRDArgs
  276.  
  277.         bra    ShutDown
  278.  
  279. DoVS03:        lea.l    ConvText1,a0
  280.         bsr    Printer
  281.         lea.l    ConvText4,a0
  282.         bsr    Printer
  283.  
  284. ;Test for optional prefs file and get prefs if possible
  285.  
  286.         move.l    Source2,d1
  287.         beq    DoVS03.2
  288.         lea.l    CopyBuffer1,a0
  289.         move.l    a0,d2
  290.         move.l    #38,d3
  291.         lib    Dos,Read
  292.         cmp.l    d3,d0
  293.         bne    NoRDArgs
  294.  
  295.         lea.l    VSVersion03,a0
  296.         lea.l    CopyBuffer1,a1
  297.         bsr    CmpStrings
  298.         tst.l    d0
  299.         bne    DoVS03.1
  300.  
  301.         lea.l    IncVerText1,a0
  302.         bsr    Printer
  303.         move.l    #RETURN_WARN,RetCode
  304.         bra    DoVS03.2
  305.  
  306. DoVS03.1:    lea.l    CopyBuffer1,a0
  307.         add.l    #4,a0            ;Skip header
  308.         lea.l    DefPrefs,a1
  309.         add.l    #4,a1            ;Skip header
  310.         move.l    #14,d0
  311.         lib    Exec,CopyMem        ;Copy prefs, part I
  312.  
  313.         lea.l    CopyBuffer1,a0
  314.         lea.l    DefPrefs,a1
  315.         move.b    18(a0),19(a1)        ;Move wake correctly
  316.         move.l    34(a0),34(a1)        ;Move Alt(X/Y)Pos
  317.  
  318. DoVS03.2:    bsr    WriteDefPrefs
  319.         tst.l    d0
  320.         beq    NoRDArgs
  321.  
  322. ;Do MapBuffer & CommandList
  323.  
  324.         move.l    Source1,d1
  325.         move.l    #(VSMB_Size+VocabSIZE*GADLENGTH),d3
  326.         bsr    CopyBytes
  327.         tst.l    d0
  328.         beq    NoRDArgs
  329.  
  330. ;Do ErrCmdList
  331.  
  332.         move.l    #(9*GADLENG2),d3        ;2304 bytes
  333.         bsr    WriteNulls
  334.         tst.l    d0
  335.         beq    NoRDArgs
  336.  
  337.         bra    ShutDown
  338.  
  339. DoVS04:        lea.l    ConvText1,a0
  340.         bsr    Printer
  341.         lea.l    ConvText5,a0
  342.         bsr    Printer
  343.  
  344. ;Test for optional prefs file and get prefs if possible
  345.  
  346.         move.l    Source2,d1
  347.         beq    DoVS04.2
  348.         lea.l    CopyBuffer1,a0
  349.         move.l    a0,d2
  350.         move.l    #38,d3
  351.         lib    Dos,Read
  352.         cmp.l    d3,d0
  353.         bne    NoRDArgs
  354.  
  355.         lea.l    VSVersion04,a0
  356.         lea.l    CopyBuffer1,a1
  357.         bsr    CmpStrings
  358.         tst.l    d0
  359.         bne    DoVS04.1
  360.  
  361.         lea.l    IncVerText1,a0
  362.         bsr    Printer
  363.         move.l    #RETURN_WARN,RetCode
  364.         bra    DoVS04.2
  365.  
  366. DoVS04.1:    lea.l    CopyBuffer1,a0
  367.         add.l    #4,a0            ;Skip header
  368.         lea.l    DefPrefs,a1
  369.         add.l    #4,a1            ;Skip header
  370.         move.l    #14,d0
  371.         lib    Exec,CopyMem        ;Copy prefs, part I
  372.  
  373.         lea.l    CopyBuffer1,a0
  374.         lea.l    DefPrefs,a1
  375.         move.b    18(a0),19(a1)        ;Move wake correctly
  376.         move.l    34(a0),34(a1)        ;Move Alt(X/Y)Pos
  377.  
  378. DoVS04.2:    bsr    WriteDefPrefs
  379.         tst.l    d0
  380.         beq    NoRDArgs
  381.  
  382. ;Do MapBuffer, CommandList & ErrorCommands
  383.  
  384.         move.l    Source1,d1
  385.         move.l    #(VSMB_Size+VocabSIZE*GADLENGTH+9*GADLENG2),d3
  386.         bsr    CopyBytes
  387.         tst.l    d0
  388.         beq    NoRDArgs
  389.         bra    ShutDown
  390.  
  391. DoVS05:        lea.l    NewestText1,a0
  392.         bsr    Printer
  393.         bra    ShutDown
  394.  
  395. DoVCLI70:    lea.l    ConvText2,a0
  396.         bsr    Printer
  397.         lea.l    ConvText9,a0
  398.         bsr    Printer
  399.  
  400. ;Seek 12+VCLIMB_Size+16*48+128*48 bytes from the start, to
  401. ;beginning of VCLI preferences in source (VCLI file)
  402.  
  403.         move.l    Source1,d1
  404.         move.l    #12+VCLIMB_Size+16*48+128*48,d2
  405.         move.l    #OFFSET_BEGINNING,d3
  406.         lib    Dos,Seek
  407.         cmp.l    #-1,d0
  408.         beq    NoRDArgs
  409.  
  410. ;Read prefs 4 bytes
  411.  
  412.         move.l    Source1,d1
  413.         lea.l    CopyBuffer1,a0
  414.         move.l    a0,d2
  415.         move.l    #4,d3
  416.         lib    Dos,Read
  417.         cmp.l    d3,d0
  418.         bne    NoRDArgs
  419.  
  420.         lea.l    CopyBuffer1,a0
  421.         lea.l    DefPrefs,a1
  422.  
  423.         move.b    (a0)+,d0
  424.         btst.b    #0,d0            ;Timer bit
  425.         bne    DoVCLI70.1
  426.         move.b    #TIMER_B,7(a1)
  427.         bra    DoVCLI70.2
  428. DoVCLI70.1:    move.b    #TIMER_A,7(a1)
  429.  
  430. DoVCLI70.2:    btst.b    #1,d0            ;Confirm
  431.         bne    DoVCLI70.3
  432.         move.b    #TRUE,11(a1)        ;Default is on
  433.         bra    DoVCLI70.4
  434. DoVCLI70.3:    move.b    #FALSE,11(a1)
  435.  
  436. DoVCLI70.4:    move.b    (a0)+,5(a1)        ;SampType
  437.         move.b    (a0),8(a1)        ;Gain
  438.  
  439. ;Write prefs
  440.  
  441.         bsr    WriteDefPrefs
  442.  
  443. ;Seek 12 bytes from the start, to beginning of MapBuffer,
  444. ;in source (VCLI file)
  445.  
  446.         move.l    Source1,d1
  447.         move.l    #12,d2
  448.         move.l    #OFFSET_BEGINNING,d3
  449.         lib    Dos,Seek
  450.         cmp.l    #-1,d0
  451.         beq    NoRDArgs
  452.  
  453. ;Copy VCLI MapBuffer to Destination (VoiceShell)
  454.  
  455.         move.l    #VCLIMB_Size,d0
  456.         bsr    CopyMapBuffer
  457.         tst.l    d0
  458.         beq    NoRDArgs
  459.  
  460. ;Correct VCLI to VoiceShell vocabulary size difference
  461. ;
  462. ;Write (VocabSIZE*304) - (VCLIVocabSIZE*304) amount of NULL to Destination
  463.  
  464.         move.l    #VSMB_Size-VCLIMB_Size,d3
  465.         bsr    WriteNulls
  466.         tst.l    d0
  467.         beq    NoRDArgs
  468.  
  469. ;Copy descriptions from Source (VCLI) to Destination (VoiceShell) with
  470. ;steps of GADLENG1. Read in 16 bytes chunks, written in GADLENG1 chunks,
  471. ;VCLIVocabSIZE times. Skip GADLENG2 in between.
  472.  
  473.         move.l    Source1,d1
  474.         lea.l    CopyBuffer1,a0
  475.         move.l    a0,d2
  476.         move.l    #VCLIVocabSIZE*16,d3
  477.         lib    Dos,Read
  478.         cmp.l    d3,d0
  479.         bne    NoRDArgs
  480.  
  481.         clr.l    d5
  482.  
  483. VCLI70.5:    move.l    d5,d0
  484.         mulu.w    #16,d0            ;Get offset
  485.         lea.l    CopyBuffer1,a0
  486.         move.l    a0,d2
  487.         add.l    d0,d2
  488.  
  489.         move.l    Destination,d1
  490.         move.l    #16,d3
  491.         lib    Dos,Write
  492.         cmp.l    d3,d0
  493.         bne    NoRDArgs
  494.  
  495.         move.l    #GADLENG2,d3        ;skip command for now
  496.         bsr    WriteNulls
  497.         tst.l    d0
  498.         beq    NoRDArgs
  499.  
  500.         add.l    #1,d5
  501.         cmp.l    #VCLIVocabSIZE,d5
  502.         bne    VCLI70.5
  503.  
  504. ;Add missing entries
  505.  
  506.         move.l    #GADLENGTH*(VocabSIZE-VCLIVocabSIZE),d3    ;skip command for now
  507.         bsr    WriteNulls
  508.         tst.l    d0
  509.         beq    NoRDArgs
  510.  
  511. ;Seek to first CLI Command string in Destination (VoiceShell)
  512. ;
  513.         move.l    Destination,d1
  514.         move.l    #38+VSMB_Size+GADLENG1,d2
  515.         move.l    #OFFSET_BEGINNING,d3
  516.         lib    Dos,Seek
  517.         cmp.l    #-1,d0
  518.         beq    NoRDArgs
  519.  
  520. ;Copy strings from Source (VCLI) to Destination (VoiceShell) with steps of
  521. ;GADLENG2. Read in 128 bytes chunks, written in GADLENG2 chunks, 
  522. ;VCLIVocabSIZE times. Skip GADLENG1 in between.
  523.  
  524.         move.l    Source1,d1
  525.         lea.l    CopyBuffer1,a0
  526.         move.l    a0,d2
  527.         move.l    #VCLIVocabSIZE*128,d3
  528.         lib    Dos,Read
  529.         cmp.l    d3,d0
  530.         bne    NoRDArgs
  531.  
  532.         clr.l    d5
  533.  
  534. VCLI70.6:    move.l    d5,d0
  535.         mulu.w    #128,d0            ;Get offset
  536.         lea.l    CopyBuffer1,a0
  537.         move.l    a0,d2
  538.         add.l    d0,d2
  539.  
  540.         move.l    Destination,d1
  541.         move.l    #128,d3
  542.         lib    Dos,Write
  543.         cmp.l    d3,d0
  544.         bne    NoRDArgs
  545.  
  546.         move.l    Destination,d1
  547.         move.l    #(GADLENG2-128)+GADLENG1,d2    ;skip description and leftovers
  548.         move.l    #OFFSET_CURRENT,d3
  549.         lib    Dos,Seek
  550.         cmp.l    #-1,d0
  551.         beq    NoRDArgs
  552.  
  553.         add.l    #1,d5
  554.         cmp.l    #VCLIVocabSIZE,d5
  555.         bne    VCLI70.6
  556.  
  557. ;Error commands
  558.  
  559.         move.l    Destination,d1
  560.         bsr    SeekEnd
  561.         cmp.l    #-1,d0
  562.         beq    NoRDArgs
  563.  
  564.         move.l    #(9*GADLENG2),d3        ;2304 bytes
  565.         bsr    WriteNulls
  566.         tst.l    d0
  567.         beq    NoRDArgs
  568.  
  569.         bra    ShutDown
  570.  
  571. GetYesNo:    move.l    _stdin,d1
  572.         move.l    #TRUE,d2
  573.         lib    Dos,SetMode
  574.  
  575.         move.l    _stdin,d1
  576.         lib    Dos,Flush
  577.  
  578.         move.l    _stdin,d1
  579.         lib    Dos,FGetC
  580.         cmp.l    #-1,d0
  581.         bne    GetYesNo2
  582.         lea.l    ErrorText1,a0
  583.         bsr    Printer
  584.         bra    GetYesNo_OUT
  585.  
  586. GetYesNo2:    cmp.l    #'y',d0
  587.         beq    GetYesNo3
  588.         cmp.l    #'Y',d0
  589.         beq    GetYesNo3
  590.         cmp.l    #'n',d0
  591.         beq    GetYesNo4
  592.         cmp.l    #'N',d0
  593.         beq    GetYesNo4
  594.         cmp.l    #13,d0
  595.         beq    GetYesNo4        ;Return
  596.         cmp.l    #10,d0
  597.         beq    GetYesNo4        ;Return
  598.         clr.l    d0
  599.         bra    GetYesNo_OUT
  600. GetYesNo3:    lea.l    YesText1,a0
  601.         bsr    Printer
  602.         move.l    #1,d0
  603.         bra    GetYesNo_OUT
  604. GetYesNo4:    lea.l    NoText1,a0
  605.         bsr    Printer
  606.         move.l    #2,d0
  607. ;        bra    GetYesNo_OUT        ;Careful!
  608. GetYesNo_OUT:    push    d0
  609.         move.l    _stdin,d1
  610.         move.l    #FALSE,d2
  611.         lib    Dos,SetMode
  612.         pull    d0
  613.         rts
  614.  
  615.  
  616. ;GetFileLength gets the length of a file and returns to the start of file
  617. ;
  618. ;Input    d1 = File
  619. ;
  620. ;Result    d0 = Length
  621. ;
  622.  
  623. GetFileLength:    move.l    d1,d3
  624.         bsr    SeekStart
  625.         cmp.l    #-1,d0
  626.         beq    GetFLength_ERR
  627.         move.l    d3,d1
  628.         bsr    SeekEnd
  629.         cmp.l    #-1,d0
  630.         beq    GetFLength_ERR
  631.         push    d0
  632.         move.l    d3,d1
  633.         bsr    SeekStart
  634.         cmp.l    #-1,d0
  635.         beq    GetFLength_ERR2
  636.         pull    d0
  637.         rts
  638.  
  639. GetFLength_ERR2: pull    d0
  640. GetFLength_ERR:    clr.l    d0
  641.         rts
  642.  
  643. ;Seek to end of file
  644. ;
  645. ;Input    d1 = File
  646. ;
  647. ;Result    d0 = Length
  648. ;
  649.  
  650. SeekEnd:    push    d2-d6
  651.         move.l    d1,d6
  652.         clr.l    d2
  653.         move.l    #OFFSET_END,d3
  654.         lib    Dos,Seek
  655.         cmp.l    #-1,d0
  656.         beq    SeekEnd_ERR
  657.         move.l    d6,d1
  658.         lib    Dos,Seek
  659. SeekEnd_ERR:    pull    d2-d6
  660.         rts
  661.  
  662. ;Seek to start of file
  663. ;
  664. ;Input    d1 = File
  665. ;
  666. ;Result    d0 = Length
  667. ;
  668.  
  669. SeekStart:    push    d2-d3
  670.         move.l    #0,d2
  671.         move.l    #OFFSET_BEGINNING,d3
  672.         lib    Dos,Seek
  673.         pull    d2-d3
  674.         rts
  675.  
  676. ;GetHeader reads 12 bytes into CopyBuffer1 and seeks to start of file
  677. ;
  678. ;Input    d1 = File
  679.  
  680. GetHeader:    move.l    d1,d4
  681.  
  682.         bsr    SeekStart
  683.         cmp.l    #-1,d0
  684.         beq    GetHeader_ERR1
  685.  
  686.         move.l    d4,d1
  687.         lea.l    CopyBuffer1,a0
  688.         move.l    a0,d2
  689.         move.l    #12,d3
  690.         lib    Dos,Read
  691.         cmp.l    #12,d0
  692.         bne    GetHeader_ERR1
  693.  
  694.         move.l    d4,d1
  695.         bsr    SeekStart
  696.         cmp.l    #-1,d0
  697.         beq    GetHeader_ERR1
  698.  
  699.         move.l    #-1,d0
  700.         rts
  701.  
  702. GetHeader_ERR1:    clr.l    d0
  703.         rts
  704.  
  705. ;WriteDefPrefs writes DefPrefsSize bytes from start of file to destination
  706. ;
  707. ;DefPrefs should be set accordingly (or left alone for defaults)
  708.  
  709. WriteDefPrefs:    move.l    Destination,d1
  710.         bsr    SeekStart
  711.         cmp.l    #-1,d0
  712.         beq    WriteDP_ERR1
  713.  
  714.         move.l    Destination,d1
  715.         lea.l    DefPrefs,a0
  716.         move.l    a0,d2
  717.         move.l    #DefPrefsSize,d3
  718.         lib    Dos,Write
  719.         cmp.l    d3,d0
  720.         bne    WriteDP_ERR1
  721.         move.l    #-1,d0
  722.         rts
  723.  
  724. WriteDP_ERR1:    clr.l    d0
  725.         rts
  726.  
  727. ;CopyMapBuffer reads d0 bytes into MapBuffer and writes them into
  728. ;destination at current point
  729. ;
  730. ;Input    d0 = Length
  731.  
  732. CopyMapBuffer:    push    d0
  733.         move.l    Source1,d1
  734.         lea.l    MapBuffer,a0
  735.         move.l    a0,d2
  736.         pull    d3
  737.         lib    Dos,Read
  738.         cmp.l    d3,d0
  739.         bne    CopyMB_ERR1
  740.  
  741.         move.l    Destination,d1
  742.         lib    Dos,Write
  743.         cmp.l    d3,d0
  744.         bne    CopyMB_ERR1
  745.         move.l    #-1,d0
  746.         rts
  747.  
  748. CopyMB_ERR1:    clr.l    d0
  749.         rts
  750.  
  751. ;CopyBytes copies asked amount from given file to destination at current
  752. ;positions. Max. length should be under 65536 bytes.
  753. ;
  754. ;Inputs    d1 = Source file
  755. ;    d3 = Length
  756. ;
  757.  
  758. CopyBytes:    lea.l    CopyBuffer1,a0
  759.         move.l    a0,d2
  760.         lib    Dos,Read
  761.         cmp.l    d3,d0
  762.         bne    CopyBytes_ERR1
  763.  
  764.         move.l    Destination,d1
  765.         lib    Dos,Write
  766.         cmp.l    d3,d0
  767.         bne    CopyBytes_ERR1
  768.         move.l    #-1,d0
  769.         rts
  770.  
  771. CopyBytes_ERR1:    clr.l    d0
  772.         rts
  773.  
  774. ;CopyGL02Bytes copies GADLENG2VS02 bytes from Source to Destination
  775. ;
  776.  
  777. CopyGL02Bytes:    move.l    Source1,d1        ;Read GADLENGTHVS02 bytes
  778.         lea.l    CopyBuffer1,a0
  779.         move.l    a0,d2
  780.         move.l    #GADLENGTHVS02,d3
  781.         lib    Dos,Read
  782.         cmp.l    #GADLENGTHVS02,d0
  783.         bne    CopyGL02_ERR1
  784.  
  785.         move.l    Destination,d1        ;Write GADLENGTHVS02 bytes
  786.         lib    Dos,Write
  787.         cmp.l    #GADLENGTHVS02,d0
  788.         bne    CopyGL02_ERR1
  789.         move.l    #-1,d0
  790.         rts
  791.  
  792. CopyGL02_ERR1:    clr.l    d0
  793.         rts
  794.  
  795. ;WriteNulls writes NULLs to Destination
  796. ;
  797. ;Inputs    d3 = Amount of NULLs to write
  798.  
  799. WriteNulls:    move.l    Destination,d1
  800.         lea.l    NullBuffer,a0
  801.         move.l    a0,d2
  802.         lib    Dos,Write
  803.         cmp.l    d3,d0
  804.         bne    WriteNull_ERR1
  805.         move.l    #-1,d0
  806.         rts
  807.  
  808. WriteNull_ERR1:    clr.l    d0
  809.         rts
  810.  
  811. CloseFiles:    move.l    Source1,d1
  812.         beq    CloseFiles2
  813.         lib    Dos,Close
  814.  
  815. CloseFiles2:    move.l    Source2,d1
  816.         beq    CloseFiles3
  817.         lib    Dos,Close
  818.  
  819. CloseFiles3:    move.l    Destination,d1
  820.         beq    CloseFiles4
  821.         lib    Dos,Close
  822. CloseFiles4:    rts
  823.  
  824. ;Compares two strings upto length of first string.
  825. ;
  826. ;Input    a0 = String 1
  827. ;    a1 = String 2
  828. ;
  829. ;Result    d0 = 0 if not same
  830. ;
  831. ;BUGS
  832. ;
  833. ;String 1 has to have NULL at end!
  834. ;
  835.  
  836. CmpStrings:    tst.b    (a0)
  837.         beq    CmpStrings2
  838.         cmp.b    (a0)+,(a1)+
  839.         beq    CmpStrings
  840.         clr.l    d0
  841.         rts
  842. CmpStrings2:    move.l    #-1,d0
  843.         rts
  844.  
  845. ;Get length of text in given address
  846. ;
  847. ;Input a0 = Address of null terminated text string
  848. ;
  849. ;Result d0 = Length
  850.  
  851. GetLength:    push    a0
  852.         clr.l    d0
  853.         cmp.l    #$00,a0        ;fixes enforcer hit
  854.         beq    GetLength_OUT
  855. GetLength2:    add.l    #1,d0
  856.         tst.b    (a0)+
  857.         bne    GetLength2
  858.         sub.l    #1,d0        ;don't include NULL
  859. GetLength_OUT:    pull    a0
  860.         rts
  861.  
  862. ShutDown:    move.l    RDArgs1,d1
  863.         beq    ShutDown9000
  864.         lib    Dos,FreeArgs
  865.  
  866. ShutDown9000:    bsr    CloseFiles
  867.  
  868. ShutDown1000:    closlib    Dos
  869.         move.l    RetCode,d0
  870.         rts
  871.  
  872. NoDos:        move.l    #RETURN_FAIL,d0
  873.         rts
  874.  
  875. NoRDArgs:    lib    Dos,IoErr
  876.         move.l    d0,d1
  877. NoRDArgs2:    clr.l    d2
  878.         lib    Dos,PrintFault
  879.         move.l    #RETURN_FAIL,RetCode
  880.         bra    ShutDown
  881.  
  882. Printer:    printa    a0
  883.         rts
  884.  
  885.  
  886. ;Library stuff
  887.  
  888.         libnames
  889.  
  890. ;Reservations
  891.  
  892. _stdin:        dc.l    0
  893. _stdout:    dc.l    0
  894. RDArgs1:    dc.l    0
  895. Source1:    dc.l    0
  896. Source2:    dc.l    0
  897. Destination:    dc.l    0
  898. RetCode:    dc.l    RETURN_OK
  899.  
  900. ;Options
  901.  
  902. CLArray1:
  903. SourceFile1:    dc.l    0
  904. SourceFile2:    dc.l    0
  905. DestFile:    dc.l    0
  906.  
  907. ;Strings, errors etc.
  908.  
  909. FExistsText1:    dc.b    13,10,"File already exists! Replace? (y/N) ",0
  910. UnknownText1:    dc.b    "Unknown file type!",13,10,13,10
  911.         dc.b    "File header was:",13,10,0
  912. NewestText1:    dc.b    13,10,"This is the newest version of the datafile ",13,10
  913.         dc.b    "for VoiceShell that this program recognizes.",13,10,13,10
  914.         dc.b    "ERROR: Can't convert to anything!",13,10,0
  915. ErrorText1:    dc.b    "Error!",13,10,0
  916.  
  917. ;Strings, others
  918.  
  919. CLTemplate1:    dc.b    "FROM/A,PREFS,TO/A/K",0
  920. VSConvVersion:    dc.b    "$VER: VoiceShell_Conversion_Utility "
  921.         PROGVERSION
  922.         dc.b    " (c) Copyright Tomi Blinnikka 1995",0
  923.  
  924. FromFileText1:    dc.b    13,10,"Data file   : ",0
  925. FromFileText2:    dc.b    "Prefs file  : ",0
  926. DestText1:    dc.b    "Destination : ",0
  927.  
  928. ConvText1:    dc.b    "Converting VoiceShell: ",0
  929. ConvText2:    dc.b    "Converting VCLI: ",0
  930. ConvText3:    dc.b    "(VS02) 1.07 - 1.11 to 1.25 (VS05).",13,10,0
  931. ConvText4:    dc.b    "(VS03) 1.12 - 1.18 to 1.25 (VS05).",13,10,0
  932. ConvText5:    dc.b    "(VS04) 1.19 - 1.24 to 1.25 (VS05).",13,10,0
  933. ConvText9:    dc.b    "VCLI 7.0 to VoiceShell 1.25 (VS05).",13,10,0
  934.  
  935. IncVerText1:    dc.b    "Incorrect preferences file version, using defaults.",13,10,0
  936.  
  937. YesText1:    dc.b    "Yes",13,10,0
  938. NoText1:    dc.b    "No",13,10,0
  939. CRLFText1:    dc.b    13,10,0
  940.  
  941.  
  942. ;File headers
  943.  
  944. VSVersion02:    dc.b    "VS02",0        ;For prefs only!
  945. VSVersion03:    dc.b    "VS03",0        ;For prefs only!
  946. VSVersion04:    dc.b    "VS04",0        ;For prefs only!
  947. VSVersion05:    dc.b    "VS05",0        ;For prefs only!
  948. VCLI70ID:    dc.b    "VCLI7.0 DATA",0
  949.  
  950.         ds.w    0
  951.  
  952. DEFPREFS_START:
  953. DefPrefs:    dc.b    "VS05"
  954.         dc.b    0
  955.         dc.b    SAMP_GENERIC
  956.         dc.b    RES_HI
  957.         dc.b    TIMER_B
  958.         dc.b    0
  959.         dc.b    CHANNEL_LEFT
  960.         dc.b    INPUT_LINE
  961.         dc.b    0
  962.         dc.l    120
  963.         dc.w    DefAccVal
  964.         dc.w    0
  965.         dc.w    0
  966.         dc.l    0
  967.         dc.l    0
  968.         dc.l    0
  969.  
  970.         dc.w    200
  971.         dc.w    31
  972.  
  973. ;Map buffer comes here
  974.  
  975. ;Command list after that
  976.  
  977. ;Error commands after that
  978.  
  979. DEFPREFS_END:    dc.l    0,0
  980.  
  981. DefPrefsSize:    EQU    (DEFPREFS_END-DEFPREFS_START)
  982.  
  983. ;Other stuff, part II
  984.  
  985.         Section VS,BSS
  986.  
  987. DATA_START:
  988.  
  989. MapBuffer:    ds.b    (VocabSIZE*304)        ;60 words
  990.  
  991. CmdList:    ds.b    (VocabSIZE*GADLENGTH)
  992.  
  993. ErrCmdList:    ds.b    (9*GADLENG2)
  994.  
  995. DATA_END:    ds.l    1
  996.  
  997. DataSize:    EQU    (DATA_END-DATA_START)
  998.  
  999.  
  1000. NullBuffer:    ds.b    NullBufSize1
  1001. CopyBuffer1:    ds.b    NullBufSize1
  1002.  
  1003.         end
  1004.  
  1005.